<template>
  <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
    <el-table-column label="类型" align="center" prop="title" />
    <el-table-column label="金额" align="center" prop="price" />
    <el-table-column label="余额" align="center" prop="balance" />
    <el-table-column
      label="创建时间"
      align="center"
      prop="createTime"
      :formatter="dateFormatter"
    />
  </el-table>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as WalletApi from '@/api/pay/wallet/balance'

const { userId, user }: { userId: number } = defineProps({
  userId: {
    type: Number,
    required: true
  }
})

const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const { id: walletId } = await WalletApi.getWallet({ userId })
    const { list: record, total } = await WalletApi.walletTransactionPage({ walletId })
    list.value = record
  } finally {
    loading.value = false
  }
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>

<style scoped lang="scss"></style>
